package cn.lizhangqu.kb.handler;

import org.json.JSONException;
import org.json.JSONObject;

import cn.lizhangqu.kb.model.LgrgNode;

/**
 * Created by 柯尊诚 on 2015/11/10.
 * kzc
 */
public class LgrgListJsonResponseHandler extends JsonResponseHandler<LgrgNode>{

    private final static String JSON_KEY_LGRG_TITLE = "title";
    private final static String JSON_KEY_LGRG_TYPE = "id";


    @Override
    protected LgrgNode parseItem(JSONObject json) throws JSONException {

        LgrgNode lgrgNode = new LgrgNode();

        if (hasKeyValue(json, JSON_KEY_LGRG_TITLE)) {
            lgrgNode.setTitle(json.getString(JSON_KEY_LGRG_TITLE));
        }

        if (hasKeyValue(json, JSON_KEY_LGRG_TYPE)) {
            lgrgNode.setId(json.getInt(JSON_KEY_LGRG_TYPE));
        }

        return lgrgNode;
    }
}
